TKey
TValue
CSharpTest.Net
LurchTable.ItemUpdatedMethod<TKey,TValue> Delegate
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace : LurchTable.ItemUpdatedMethod<TKey,TValue> Delegate

previous
next

Glossary Item Box

Method signature for the ItemUpdated event

Syntax

Visual Basic (Declaration) 
Public Delegate Sub LurchTable.ItemUpdatedMethod
    (Of TKey,TValue)( _
   ByVal  As KeyValuePair(Of TKey,TValue), _
   ByVal  As KeyValuePair(Of TKey,TValue) _
) 
C# 
public delegate void LurchTable.ItemUpdatedMethod<TKey,TValue>( 
   KeyValuePair<TKey,TValue> ,
   KeyValuePair<TKey,TValue> 
)

Parameters

previous
next

Type Parameters

TKey
TValue

Example

Library/Library.Test/TestLurchTable.cs

C#Copy Code
var recorder = new RecordEvents<int, string>();
var test = new LurchTable<int, string>(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer<int>.Default);
test.ItemAdded += recorder.ItemAdded;
test.ItemUpdated += recorder.ItemUpdated;
test.ItemRemoved += recorder.ItemRemoved;
test[1] = "a";
Assert.AreEqual("a", recorder.LastAdded.Value);
test[2] = "b";
Assert.AreEqual("b", recorder.LastAdded.Value);
test[3] = "c";
Assert.AreEqual("c", recorder.LastAdded.Value);
Assert.AreEqual(3, test.Count);
Assert.AreEqual("b", test[2]); //access moves to front..
test[4] = "d";
Assert.AreEqual("d", recorder.LastAdded.Value);
Assert.AreEqual("a", recorder.LastRemove.Value);
test[5] = "e";
Assert.AreEqual("e", recorder.LastAdded.Value);
Assert.AreEqual("c", recorder.LastRemove.Value);
test[2] = "B";
Assert.AreEqual("B", recorder.LastUpdate.Value);
test[6] = "f";
Assert.AreEqual("f", recorder.LastAdded.Value);
Assert.AreEqual("d", recorder.LastRemove.Value);

Assert.AreEqual(3, test.Count); // still 3 items
string value;
Assert.IsTrue(test.TryRemove(5, out value));
Assert.AreEqual("e", value);
Assert.AreEqual("e", recorder.LastRemove.Value);

Assert.AreEqual("B", test.Dequeue().Value);
Assert.AreEqual("f", test.Dequeue().Value);
Assert.AreEqual(0, test.Count);
VB.NETCopy Code
Dim recorder As var = New RecordEvents(Of Integer, String)()
Dim test As var = New LurchTable(Of Integer, String)(LurchTableOrder.Access, 3, 1103, 10, 10, EqualityComparer(Of Integer).[Default])
test.ItemAdded += recorder.ItemAdded
test.ItemUpdated += recorder.ItemUpdated
test.ItemRemoved += recorder.ItemRemoved
test(1) = "a"
Assert.AreEqual("a", recorder.LastAdded.Value)
test(2) = "b"
Assert.AreEqual("b", recorder.LastAdded.Value)
test(3) = "c"
Assert.AreEqual("c", recorder.LastAdded.Value)
Assert.AreEqual(3, test.Count)
Assert.AreEqual("b", test(2))
'access moves to front..
test(4) = "d"
Assert.AreEqual("d", recorder.LastAdded.Value)
Assert.AreEqual("a", recorder.LastRemove.Value)
test(5) = "e"
Assert.AreEqual("e", recorder.LastAdded.Value)
Assert.AreEqual("c", recorder.LastRemove.Value)
test(2) = "B"
Assert.AreEqual("B", recorder.LastUpdate.Value)
test(6) = "f"
Assert.AreEqual("f", recorder.LastAdded.Value)
Assert.AreEqual("d", recorder.LastRemove.Value)

Assert.AreEqual(3, test.Count)
' still 3 items
Dim value As String
Assert.IsTrue(test.TryRemove(5, value))
Assert.AreEqual("e", value)
Assert.AreEqual("e", recorder.LastRemove.Value)

Assert.AreEqual("B", test.Dequeue().Value)
Assert.AreEqual("f", test.Dequeue().Value)
Assert.AreEqual(0, test.Count)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys